import { resultSuccess, resultError, getRequestToken, requestParams } from "../_util";
import { MockMethod } from "vite-plugin-mock";

const dashboardRoute = {
  path: "/dashboard",
  name: "Dashboard",
  component: "/dashboard/home/index",
  meta: {
    title: "首页",
    icon: "bx:bx-home",
  },
};

const accountRoute = {
  path: "/account",
  name: "Account",
  component: "/account/index",
  meta: {
    title: "个人设置",
    hideMenu: true,
  },
};

// @ts-ignore
const practicalStudent = {
  path: "/student",
  name: "Student",
  component: "LAYOUT",
  meta: {
    icon: "bx:task",
    title: "实习记录",
  },
  children: [
    {
      path: "info",
      name: "Info",
      component: "/student/practical/info/index.vue",
      meta: {
        icon: "fluent:person-info-20-regular",
        title: "实习信息",
      },
    },
    {
      path: "task",
      name: "Task",
      component: "/student/practical/task/index.vue",
      meta: {
        icon: "clarity:note-edit-line",
        title: "实习任务",
      },
    },
    // 小组长可见路由
    {
      path: "mark",
      name: "Mark",
      component: "/captain/practical/index.vue",
      meta: {
        icon: "ri:mark-pen-line",
        title: "小组评价",
      },
    },
  ],
};

const practicalTeacher = {
  path: "/teacher",
  name: "Teacher",
  component: "LAYOUT",
  meta: {
    icon: "bx:comment-edit",
    title: "实习评价",
  },
  children: [
    {
      path: "menber",
      name: "Member",
      component: "/teacher/practical/member/index.vue",
      meta: {
        icon: "fluent:people-12-regular",
        title: "成员信息",
      },
    },
  ],
};

const groupTeacher = {
  path: "/groupt",
  name: "Groupt",
  component: "LAYOUT",
  meta: {
    icon: "akar-icons:people-group",
    title: "我的小组t",
  },
  children: [
    {
      path: "apply",
      name: "Apply",
      component: "/teacher/group/apply/index.vue",
      meta: {
        icon: "bx:message-square-detail",
        title: "申请列表",
      },
    },
    {
      path: "group",
      name: "Group",
      component: "/teacher/group/list/index.vue",
      meta: {
        icon: "bi:card-list",
        title: "小组列表",
      },
    },
    {
      path: "manage",
      name: "Manage",
      component: "/teacher/group/manage/index.vue",
      meta: {
        hideMenu: true,
        title: "小组管理",
        currentActiveMenu: "/groupt/group",
      },
    },
  ],
};

const groupStudent = {
  path: "/groups",
  name: "Groups",
  component: "LAYOUT",
  meta: {
    icon: "akar-icons:people-group",
    title: "我的小组s",
  },
  children: [
    {
      path: "join",
      name: "Join",
      component: "/student/group/join/index.vue",
      meta: {
        icon: "akar-icons:comment-add",
        title: "加入小组",
      },
    },
    {
      path: "list",
      name: "List",
      component: "/student/group/list/index.vue",
      meta: {
        icon: "bi:card-list",
        title: "小组列表",
      },
    },
    {
      path: "detail",
      name: "Detail",
      component: "/student/group/detail/index.vue",
      meta: {
        hideMenu: true,
        title: "小组信息",
        currentActiveMenu: "/groups/join",
      },
    },
  ],
};

const lectureNoteRoute = {
  path: "lectureNoteList",
  name: "LectureNoteList",
  component: "/default/practical/LectureNoteList.vue",
  meta: {
    title: "听课记录列表",
    hideMenu: true,
  },
};

const lessonPlanRoute = {
  path: "lessonPlanList",
  name: "LessonPlanList",
  component: "/default/practical/LessonPlanList.vue",
  meta: {
    title: "实习教案列表",
    hideMenu: true,
  },
};

const teachingStudyRoute = {
  path: "teachingStudyList",
  name: "TeachingStudyList",
  component: "/default/practical/TeachingStudyList.vue",
  meta: {
    title: "教研活动列表",
    hideMenu: true,
  },
};

const teachingRecordRoute = {
  path: "teachingRecordList",
  name: "TeachingRecordList",
  component: "/default/practical/TeachingRecordList.vue",
  meta: {
    title: "课堂教学记录列表",
    hideMenu: true,
  },
};

const leaderWorkRoute = {
  path: "leaderWorkDesc",
  name: "LeaderWorkDesc",
  component: "/default/practical/LeaderWorkDesc.vue",
  meta: {
    title: "班主任实习记录",
    hideMenu: true,
  },
};

const rootRouter = {
  path: "/root",
  name: "Root",
  component: "LAYOUT",
  meta: {
    icon: "ion:settings-outline",
    title: "系统管理",
  },
  children: [
    {
      path: "college",
      name: "College",
      component: "/root/college/index.vue",
      meta: {
        icon: "maki:college",
        title: "学院管理",
      },
    },
  ],
};

export default [
  {
    url: "/dev-api/getRouters",
    timeout: 1000,
    method: "get",
    response: (request: requestParams) => {
      const token = getRequestToken(request);
      if (!token) {
        return resultError("Invalid token!");
      }

      // 学生和老师的实习模块跟路由一致，所以只能启用一个
      const menu = [
        dashboardRoute,
        lectureNoteRoute,
        lessonPlanRoute,
        teachingStudyRoute,
        teachingRecordRoute,
        leaderWorkRoute,
        accountRoute,
        rootRouter,
        practicalStudent,
        practicalTeacher,
        groupTeacher,
        groupStudent,
      ];

      return resultSuccess(menu);
    },
  },
] as MockMethod[];
